import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SessionsVO, SessionsForm, SessionsQuery } from '@/api/tomato/sessions/types';

/**
 * 查询番茄记录列表
 * @param query
 * @returns {*}
 */

export const listSessions = (query?: SessionsQuery): AxiosPromise<SessionsVO[]> => {
  return request({
    url: '/tomato/sessions/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询番茄记录详细
 * @param id
 */
export const getSessions = (id: string | number): AxiosPromise<SessionsVO> => {
  return request({
    url: '/tomato/sessions/' + id,
    method: 'get'
  });
};

/**
 * 新增番茄记录
 * @param data
 */
export const addSessions = (data: SessionsForm) => {
  return request({
    url: '/tomato/sessions',
    method: 'post',
    data: data
  });
};

/**
 * 修改番茄记录
 * @param data
 */
export const updateSessions = (data: SessionsForm) => {
  return request({
    url: '/tomato/sessions',
    method: 'put',
    data: data
  });
};

/**
 * 删除番茄记录
 * @param id
 */
export const delSessions = (id: string | number | Array<string | number>) => {
  return request({
    url: '/tomato/sessions/' + id,
    method: 'delete'
  });
};
